#pragma once

//following code from Szymon Gatner's article on type-safe message systems
//http://www.gamedev.net/reference/programming/features/effeventcpp/
//No license was given, so I assume it is public domain

#include <typeinfo>

//RTTI utils

class TypeInfoW
{
public:
	explicit TypeInfoW(const type_info& info) : _typeInfo(info) {};

	bool operator < (const TypeInfoW& rhs) const
	{
		return _typeInfo.before(rhs._typeInfo) != 0;
	}

	inline const std::type_info& getTypeInfo()const
	{
		return _typeInfo;
	}

private:
	const std::type_info& _typeInfo;

///////////////////////////////////////////////////////////////////

public:
	//! Allows use of a type_info* in a map
	//see http://www.ddj.com/cpp/184403811

	struct TypeInfoComparator : std::binary_function<std::type_info*, std::type_info*, bool> 
	{
		inline bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
		{ return lhs->before(*rhs) != 0; }
	};  

};




//RTTI utils
template <typename T>
const unsigned calcHashOfType()
{
	return (const unsigned) typeid(T).hash_code();
}

template <typename T>
const std::string calcNameOfType()
{
	const char* n = (typeid(T).name());
	return std::string (n);
}

